package com.sgb.knowledgeshare.view.adapter;

import android.content.Context;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.CircleCrop;
import com.bumptech.glide.request.RequestOptions;
import com.sgb.knowledgeshare.BR;
import com.sgb.knowledgeshare.R;
import com.sgb.knowledgeshare.entity.FollowListEntity;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;
import java.util.List;

/**
 * Created by fq on 2020/9/10 0010
 * Description：分享-用户中心-粉丝和关注列表
 */
public class ShareUserFansAdapter extends BaseRecycleAdapter<FollowListEntity.RecordsBean>{

    public ShareUserFansAdapter(Context context, List<FollowListEntity.RecordsBean> datas) {
        super(context, R.layout.item_share_userfans, datas);
    }

    @Override
    public void convert(ItemViewHolder holder, FollowListEntity.RecordsBean bean) {
        holder.setBinding(BR.viewModel, bean);
        TextView userFansState = holder.itemView.findViewById(R.id.user_fans_state);//是否关注
        TextView userFansName = holder.itemView.findViewById(R.id.user_fans_name);//用户姓名
        ImageView userFansLogo = holder.itemView.findViewById(R.id.user_fans_logo);//用户头像
        userFansName.setText(bean.getName());
        Glide.with(context).load(bean.getPhoto())
                .apply(RequestOptions.bitmapTransform(new CircleCrop()).placeholder(R.mipmap.share_def_photo))
                .into(userFansLogo);
        int isFollow = bean.getIsFollow();
        switch (isFollow){
            case 0://未关注
                userFansState.setBackground(context.getResources().getDrawable(R.drawable.bg_item_report_type_select));
                userFansState.setText("关注");
                break;
            case 1://已关注
                userFansState.setBackground(context.getResources().getDrawable(R.drawable.bg_item_share_type_normal));
                userFansState.setText("已关注");
                break;
            case 2://相互关注
                userFansState.setBackground(context.getResources().getDrawable(R.drawable.bg_item_share_type_normal));
                userFansState.setText("互相关注");
                break;
        }
//       关注状态请求参数
        userFansState.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                fensData.fens(bean.getUserNo());
            }
        });
    }
    private FensData fensData;

    public void setFensData(FensData fensData) {
        this.fensData = fensData;
    }

    public interface FensData{
        void fens(String UserNo);
    }
}
